xlv.obj.dmTrigger={
	extend:function(){
	},
	implement:function(){
		this.implement('xlv.imp.mvc');
	},
	create:function(tag){
		var div=document.createElement((tag||'div'));
		div.setAttribute('xlvobject','xlv.obj.dmTrigger');
		return div;			
	},
	properties:{
		enabled:true,
		dmName:null,
		listener:null,//{when:'afterModelChanged',notify:'setChanged',memoType:'create',memoMethods:null}
		valueMap:null,
		dmTargetName:null,
		methodName:null,
		options:null
	},
	method:{
		initial:function(){
			this.addEventHandler('click','_click');
			this.enabled(this.$P.enabled);
		},
		enabled:function(enabled){
			this.$V.enabled=enabled;
		},
		_click:function(e){
			this.process();
		},
		notified:function(when,notify,memo){
			if(!this.$V.enabled)return false;
			this.$V.when=when;
			this.$V.notify=notify;
			this.$V.memo=memo;
			var lis=this.$P.listener;
			return (lis.when==when) && 
			       ((!lis.notify)? true:(lis.notify==notify)) && 
			       ((!lis.memoType)? true:(lis.memoType==memo.type)) &&
			       ((!lis.memoMethods)? true:(memo.methods.indexOf(lis.memoMethods) > -1));

		},
		verified:function(when,notify,memo){
			return true;
		},
		valueMap:function(){
			var dm=this.mvc_getModel();
			var dm_target=this.mvc_getModel(this.$P.dmTargetName);
			var map=this.$P.valueMap;
			if(dm&&dm_target&&map){
				for(var v in map){
					var value=dm.getValue(v);
					if(value!=null)dm_target.setValue(value,map[v]);
				}
			}
		},
		process:function(options){
			if(!this.$V.enabled)return;
			this.valueMap();
			if(this.$P.methodName && this.$P.dmTargetName){
				var dm=this.mvc_getModel(this.$P.dmTargetName);
				options=(options||this.$P.options);
				if(dm && dm[this.$P.methodName])dm[this.$P.methodName](options);
			}
		},
		mvc_beforeModelChanged:function(dm,notify,memo){
			if(this.notified('beforeModelChanged',notify,memo)&&
			   this.verified('beforeModelChanged',notify,memo))	this.process();
		},
		mvc_modelChanged:function(dm,notify,memo){
			if(this.notified('modelChanged',notify,memo)&&
			   this.verified('modelChanged',notify,memo))this.process();
		},
		mvc_afterModelChanged:function(dm,notify,memo){
			if(this.notified('afterModelChanged',notify,memo)&&
			   this.verified('afterModelChanged',notify,memo)) this.process();
		},
		mvc_enableControl:function(dm){
		}
	}
};
